package cn.ctyun.xstore.s3.api.bucket;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.BucketPolicy;

import cn.ctyun.xstore.s3.client.AwsS3ClientBuilder;


public class GetBucketPolicy {
    public static void getBucketPolicy(String bucketName, AmazonS3 s3) {
        try {
            BucketPolicy bucketPolicy = s3.getBucketPolicy(bucketName);
            String policyText = bucketPolicy.getPolicyText();
            System.out.println(policyText);
        } catch (AmazonServiceException e) {
            System.err.println(e.getErrorMessage());
        }
        System.out.println("Done!");
    }
}
